#include "Transaction.hh"
#include <iomanip>
#include <sstream>
#include <random>

Transaction::Transaction(const std::string& srcAccId, 
                       const std::string& destAccId, 
                       double amt, 
                       const std::string& transType,
                       const std::string& noteText)
    : sourceAccountId(srcAccId)
    , destinationAccountId(destAccId)
    , amount(amt)
    , type(transType)
    , note(noteText) {
    transactionId = generateTransactionId();
    timestamp = std::time(nullptr);
}

std::string Transaction::generateTransactionId() {
    static int counter = 0;
    std::stringstream ss;
    ss << "T" << std::setw(3) << std::setfill('0') << ++counter;
    return ss.str();
}